<?php
/*
 * $type
 * $require
 * $label
 * $key
 * $class
 *
 * array(
    'type'=>,
'require'=>,
'label'=>,
'key'=>,
'class'=>

);
 */
$session=$this->session;

$open_html='<td><input name="'.$key.'_open" type="checkbox" id="'.$key.'_open" value="1" '.(isset($session[$key.'_open']) && $session[$key.'_open']==1 ? 'checked="checked"': '').' />&nbsp;公开</td>';
if($type=='text' || $type=='password'):

    echo '
    <td align="right" width="180"><span class="f00">'.($require==true ? '*' : '').'</span>'.$label.'：</td>
    <td width="680"><input name="'.$key.'" type="'.$type.'" class="'.(isset($class) ? $class : 'text').'" id="'.$key.'" value="'.(isset($session[$key]) ? $session[$key] : '').'" />';
    echo (isset($msg)) ? '<span>'.$msg.'</span></td>': '';
    echo (isset($open) && $open==true) ? $open_html: '';

elseif($type=='concate'):
    echo '<td align="right" width="80"><span class="f00">'.($require==true ? '*' : '').'</span>'.$label.'：</td><td>';
    $this->renderPartial('ymd',array('year'=>$session['year'], 'month'=>$session['month'], 'day'=>$session['day'], 'ystart'=>1930));
    echo (isset($msg)) ? '<span>'.$msg.'</span></td>': '';
    echo (isset($open) && $open==true) ? $open_html: '';
elseif($type=='year'): ?>

    <td align="right"><span class="f00"><?php echo $require==true? '*': '';?></span><?php echo $label;?>：</td>
    <td>
        <span><select id="<?php echo $key;?>" name="<?php echo $key;?>" class="year">
            <option <?php echo (isset($session[$key]) && 0==$session[$key]) ? 'selected="selected"':''; ?> value="0">请选择</option>
    <?php

    for($i=date("Y")+10;$i>=1980;$i--){
    echo  '<option '.(isset($session[$key]) && $i==$session[$key] ? 'selected="selected"':'').' value="'.$i.'">'.$i.'</option>';
    }
    ?>
        </select></span>
        <span>年</span>
    </td>

<?php echo (isset($open) && $open==true) ? $open_html: '';
elseif($type=='textarea'): ?>

    <td colspan="<?php echo isset($colspan_head) ? $colspan_head : '2';?>">
        <span class="f00">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $require==true? '*': '';?></span><?php echo $label;?>：
<?php echo (isset($msg)) ? '<span>'.$msg.'</span>': '';?> </td>
    <td><input name="<?php echo $key.'_open';?>" type="checkbox" id="<?php echo $key.'_open';?>" value="1" <?php
        echo (isset($session[$key.'_open']) && 1==$session[$key.'_open']) ? 'checked="checked"':''; ?> />&nbsp;公开</td>
    </tr>
    <tr>
    <td colspan="<?php echo isset($colspan_body) ? $colspan_body : '3';?>" align="center">
    <textarea name="<?php echo $key;?>" id="<?php echo $key;?>" class="<?php
        echo isset($class) ? $class : 'texta576';?>" cols="100" rows="7"><?php
        echo isset($session[$key]) ? $session[$key] :''; ?></textarea></td>

<?php elseif($type=='ltext'):?>

        <td colspan="2"><span class="f00">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $require==true? '*': '';?></span><?php echo $label;?>：</td>
        <td><input name="<?php echo $key.'_open';?>" type="checkbox"  id="<?php echo $key.'_open';?>" value="1" <?php
            echo (isset($session[$key.'_open']) && 1==$session[$key.'_open']) ? 'checked="checked"':''; ?> />&nbsp;公开</td>
    </tr>
    <tr>
        <td></td>
        <td colspan="3" align="left" ><input name="<?php echo $key;?>" type="text" class="<?php
            echo isset($class) ? $class : 'text576';?>" id="<?php echo $key;?>" value="<?php
            echo isset($session[$key]) ? $session[$key] : '';?>" /></td>

<?php elseif($type=='radio'):?>

    <td width="219" align="right"><span class="f00"><?php echo $require==true? '*': '';?></span><?php echo $label;?>：</td>

    <td width="425">
        <?php
        $i=1;
        if(!empty($range)&&is_array($range)) foreach($range as $val){?>
        <input name="<?php echo $key;?>" type="radio" class="radio" id="<?php echo $key.$i;?>" value="<?php echo $i;?>" <?php
            echo (isset($session[$key]) && $i==$session[$key]) ? 'checked="checked"':''; ?> />
        <label for="<?php echo $key.$i;?>"><?php echo $val;?></label>
        <?php
        $i++;
        }?>
    <?php echo (isset($msg)) ? '<span>'.$msg.'</span>': '';?> </td>
    <td width="64"><input name="<?php echo $key.'_open';?>" type="checkbox" id="<?php echo $key.'_open';?>" value="1" <?php
        if(isset($session[$key.'_open']) && $session[$key.'_open']==1) echo 'checked="checked"';?> />&nbsp;公开</td>

<?php elseif($type=='date'):
    /*
    $cs=Yii::app()->clientScript;
//    $cs->registerCoreCss('jquery.ui');
    $cs->registerCssFile(Yii::app()->request->baseUrl.'/css/smoothness/jquery-ui-1.8.21.custom.css',CClientScript::POS_HEAD);
    $cs->registerScriptFile(Yii::app()->request->baseUrl.'/js/jquery.ui.datepicker.js',CClientScript::POS_HEAD);
    $cs->registerScriptFile(Yii::app()->request->baseUrl.'/js/jquery-ui-1.8.21.custom.min.js',CClientScript::POS_HEAD);
    $cs->registerScriptFile(Yii::app()->request->baseUrl.'/js/date.js',CClientScript::POS_HEAD);
?>
    <td align="right"><span class="f00"><?php echo $require==true? '*': '';?></span><?php echo $label;?>：</td>
    <td><input type="text" readonly="readonly" id="<?php echo $key;?>" class="<?php echo isset($class) ? $class : 'text120 hasDatepicker';?>" name="<?php echo $key;?>" value="<?php
        echo isset($session[$key]) ? $session[$key] : '';?>"/></td>
    <?php echo (isset($msg)) ? '<td width="200px"><span>'.$msg.'</span></td>': '';?>
    <td><input name="<?php echo $key.'_open';?>" type="checkbox"  id="<?php echo $key.'_open';?>" value="1" <?php
        echo (isset($session[$key.'_open']) && 1==$session[$key.'_open']) ? 'checked="checked"':''; ?> />&nbsp;公开</td>

<?php
    */
    ?>
    <td width="219" align="right"><span class="f00"><?php echo $require==true? '*': '';?></span><?php echo $label;?>：</td>
    <td>
<?php
    $this->widget('zii.widgets.jui.CJuiDatePicker',array(
        'attribute'=>'stime',
        'language'=>'zh_cn',
        'name'=>$key,
        'value'=> isset($session[$key]) ? $session[$key] : '',
        'options'=>array(
            'showAnim'=>'fold',
            'showOn'=>'both',
            'buttonImage'=>Yii::app()->request->baseUrl.'/images/date.gif',
            'buttonImageOnly'=>false,
            'dateFormat'=>'yymmdd',
            'changeYear'=>true,
        ),
        'htmlOptions'=>array(
            'class'=>'text80',
            'readonly'=>'readonly'
        ),
    ));
?>
    <?php echo (isset($msg)) ? '<span>'.$msg.'</span>': '';?> </td>
    <td width="64"><input name="<?php echo $key.'_open';?>" type="checkbox" id="<?php echo $key.'_open';?>" value="1" <?php
        if(isset($session[$key.'_open']) && $session[$key.'_open']==1) echo 'checked="checked"';?> />&nbsp;公开</td>

    <?php elseif($type=='file'):?>

    <td align="right"><span class="f00"><?php echo $require==true? '*': '';?></span><?php echo $label;?>：</td>
    <td colspan="1" id="<?php echo $key;?>_new">
        <?php if(!empty($session[$key])):
        echo CHtml::image($session[$key],$label,array('style'=>'max-width:400px;'));
        echo CHtml::button('重新选择',array('onClick'=>$key.'_new();'));
        else:?>
        <input name="<?php echo $key;?>" type="file" class="file2" />
        <?php echo (isset($msg)) ? '<span>'.$msg.'</span>': '';?></td>
        <?php endif;?>

<?php endif;?>